package com.ruoyi.quartz.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.quartz.domain.BaseBanner;
import com.ruoyi.quartz.domain.BaseInfo;
import com.ruoyi.quartz.service.IBaseBannerService;
import com.ruoyi.quartz.service.IBaseInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/base/baseInfo")
public class BaseInfoController extends BaseController {

    @Resource
    private IBaseInfoService iBaseInfoService;

    @GetMapping("/list")
    public TableDataInfo list(BaseInfo baseInfo)
    {
        startPage();
        List<BaseInfo> list = iBaseInfoService.selectAll(baseInfo);
        return getDataTable(list);
    }

    @PostMapping
    public AjaxResult add(@RequestBody BaseInfo baseInfo) {
        return toAjax(iBaseInfoService.addBanner(baseInfo));
    }

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Integer id)
    {
        return success(iBaseInfoService.selectBannerById(id));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BaseInfo baseInfo){
        return toAjax(iBaseInfoService.updateBanner(baseInfo));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids){
        iBaseInfoService.deleteBannerByIds(ids);
        return success();
    }

}
